

var supplierId = document.getElementById("supplierId");
var supperError = document.getElementById("supperError");
var alter_image = document.getElementById("alter_image");

supplierId.onblur = IsRight;
supplierId.oninput = changePass;
alter_image.onclick=alter;

function alter(){
    $("#fileupload").removeAttr("disabled");
    $("#fileupload").click();
}

function IsRight(){
    var n = Math.floor(Number(supplierId.value));

    if(!(n !== Infinity && String(n) === supplierId.value && n >= 0)){
        supperError.innerText="请输入整数";
        supperError.setAttribute("class","ErrorMessage");
    }

}

function  changePass(){
    supperError.innerText = "";
}

$("#fileupload").change(function() {

    console.info("www");
    var $file = $(this);
    var objUrl = $file[0].files[0];
    //获得一个http格式的url路径:mozilla(firefox)||webkit or chrome
    var windowURL = window.URL || window.webkitURL;
    //createObjectURL创建一个指向该参数对象(图片)的URL
    var dataURL;
    dataURL = windowURL.createObjectURL(objUrl);
    //把url给图片的src，让其显示
    $("#imageview").attr("src",dataURL);
});

$(document).ready(function () {
    $("#editItemTable").submit(function () {
         if(supperError.innerText != ""){
            alert("请输入整数");
            supplierId.focus();
            return false;
        }
        return true;
    })
})
